libxc: suspend: Fix suspend event channel locking
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 11 Dec 2013 16:29:38 +0000 (16:29 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 17 Mar 2014 15:53:59 +0000 (15:53 +0000)
commit7b0360b76116d9b104798f1f533548d436ca50e6
tree1806a76d050fce7f70db7fb112588b4c1a5dab73
parentd310a8339c5e7257d046e482a0e84002aa895f3b
libxc: suspend: Fix suspend event channel locking

Use fcntl F_SETLK, rather than writing our pid into a "lock" file.
That way if we crash we don't leave the lockfile lying about.  Callers
now need to keep the fd for our lockfile.  (We don't use flock because
we don't want anyone who inherits this fd across fork to end up with a
handle onto the lock.)

While we are here:
 * Move the lockfile to /var/run/xen
 * De-duplicate the calculation of the pathname
 * Compute the buffer size for the pathname so that it will definitely
   not overrun (and use the computed value everywhere)
 * Fix various error handling bugs

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
tools/libxc/xc_suspend.c
tools/libxc/xenguest.h
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.h
tools/misc/xen-hptool.c
tools/python/xen/lowlevel/checkpoint/checkpoint.h
tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
tools/xcutils/xc_save.c